Skip to content

Param edit table tests#1019

Merged
amilcarlucas merged 1 commit into
masterfrom
param_edit_table_tests
Nov 5, 2025
Merged

Param edit table tests#1019
amilcarlucas merged 1 commit into
masterfrom
param_edit_table_tests

Conversation

@amilcarlucas

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings November 5, 2025 20:30
@amilcarlucas amilcarlucas force-pushed the param_edit_table_tests branch from 7f327a9 to d09ceca Compare November 5, 2025 20:31
@amilcarlucas amilcarlucas force-pushed the param_edit_table_tests branch from d09ceca to 801efa1 Compare November 5, 2025 20:44
@github-actions

github-actions Bot commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
8908 7470 84% 80% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_table.py 70% 🟢
TOTAL 70% 🟢

updated for commit: 801efa1 by action🐍

@github-actions

github-actions Bot commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

Test Results

    3 files  ±0      3 suites  ±0   2m 52s ⏱️ +3s
2 009 tests +1  2 007 ✅ +1  2 💤 ±0  0 ❌ ±0 
6 027 runs  +3  6 021 ✅ +3  6 💤 ±0  0 ❌ ±0 

Results for commit 801efa1. ± Comparison against base commit f9fed24.

This pull request removes 18 and adds 19 tests. Note that renamed tests count towards both.
tests.test_frontend_tkinter_parameter_editor_table.TestColumnManagementBehavior ‑ test_configure_table_columns_with_upload
tests.test_frontend_tkinter_parameter_editor_table.TestColumnManagementBehavior ‑ test_configure_table_columns_without_upload
tests.test_frontend_tkinter_parameter_editor_table.TestColumnManagementBehavior ‑ test_create_column_widgets_normal_parameter
tests.test_frontend_tkinter_parameter_editor_table.TestColumnManagementBehavior ‑ test_create_column_widgets_without_upload
tests.test_frontend_tkinter_parameter_editor_table.TestColumnManagementBehavior ‑ test_grid_column_widgets_with_upload
tests.test_frontend_tkinter_parameter_editor_table.TestColumnManagementBehavior ‑ test_grid_column_widgets_without_upload
tests.test_frontend_tkinter_parameter_editor_table.TestUpdateMethodsBehavior ‑ test_update_combobox_style_on_selection_valid
tests.test_frontend_tkinter_parameter_editor_table.TestUpdateMethodsBehavior ‑ test_update_new_value_entry_text_combobox
tests.test_frontend_tkinter_parameter_editor_table.TestUpdateMethodsBehavior ‑ test_update_new_value_entry_text_normal_entry
tests.test_frontend_tkinter_parameter_editor_table.TestWidgetCreationBehavior ‑ test_create_change_reason_entry_forced
…
tests.gui_frontend_tkinter_parameter_editor_table.TestParameterEditorTableUserWorkflows ‑ test_user_can_edit_multiple_parameters_in_complete_workflow
tests.gui_frontend_tkinter_parameter_editor_table.TestParameterEditorTableUserWorkflows ‑ test_user_can_switch_between_gui_complexity_modes_seamlessly
tests.gui_frontend_tkinter_parameter_editor_table.TestParameterEditorTableUserWorkflows ‑ test_user_recovers_gracefully_from_validation_errors
tests.test_frontend_tkinter_parameter_editor_table.TestParameterValueUpdateHandling ‑ test_handle_parameter_value_update_invalid_value
tests.test_frontend_tkinter_parameter_editor_table.TestParameterValueUpdateHandling ‑ test_handle_parameter_value_update_out_of_range_accepted
tests.test_frontend_tkinter_parameter_editor_table.TestParameterValueUpdateHandling ‑ test_handle_parameter_value_update_out_of_range_no_prompt
tests.test_frontend_tkinter_parameter_editor_table.TestParameterValueUpdateHandling ‑ test_handle_parameter_value_update_out_of_range_rejected
tests.test_frontend_tkinter_parameter_editor_table.TestParameterValueUpdateHandling ‑ test_handle_parameter_value_update_success
tests.test_frontend_tkinter_parameter_editor_table.TestParameterValueUpdateHandling ‑ test_handle_parameter_value_update_type_error
tests.test_frontend_tkinter_parameter_editor_table.TestParameterValueUpdateHandling ‑ test_handle_parameter_value_update_unchanged
…

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors parameter value update error handling by introducing a centralized _handle_parameter_value_update method to consolidate duplicate error handling logic across multiple widget interaction points (entry fields, comboboxes, and bitmask editors). The centralization improves code maintainability and consistency in user-facing error messages.

  • Adds _handle_parameter_value_update() method to centralize parameter validation and error handling
  • Replaces duplicated try-except blocks in entry change handlers, combobox selection handlers, and bitmask editor with calls to the centralized method
  • Expands test coverage with new tests for parameter value update handling, UI error/info display, and widget creation edge cases

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/test_frontend_tkinter_parameter_editor_table.py Adds comprehensive tests for centralized error handling, including success, unchanged values, out-of-range scenarios, and type errors; adds tests for UI error/info messaging and widget styling
tests/gui_frontend_tkinter_parameter_editor_table.py Adds helper function for creating mock parameters and new user workflow tests for multi-parameter editing, GUI complexity switching, and validation error recovery
ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_table.py Implements centralized _handle_parameter_value_update() method and refactors three call sites to use it instead of duplicated error handling
Comments suppressed due to low confidence (2)

tests/gui_frontend_tkinter_parameter_editor_table.py:1

  • Use of Union from typing module is outdated for Python 3.10+. The modern syntax uses | operator (which is already used on lines 37, 39-41, 44-45). Either remove this import and update line 38 to use dict | None, or consistently use Union throughout. The codebase appears to prefer the | syntax based on the actual usage.
#!/usr/bin/env python3

tests/gui_frontend_tkinter_parameter_editor_table.py:1

  • This helper function is nearly identical to the one in test_frontend_tkinter_parameter_editor_table.py (lines 38-82), creating code duplication. The two functions have different parameter signatures and logic (this one has min/max_value parameters, the other has is_bitmask/is_multiple_choice/is_derived). Consider consolidating into a shared test utility module to reduce duplication and ensure consistency across test files.
#!/usr/bin/env python3

from ardupilot_methodic_configurator.backend_filesystem import LocalFilesystem
from ardupilot_methodic_configurator.configuration_manager import ConfigurationManager, InvalidParameterNameError
from ardupilot_methodic_configurator.data_model_ardupilot_parameter import ArduPilotParameter
from ardupilot_methodic_configurator.data_model_ardupilot_parameter import ArduPilotParameter, ParameterUnchangedError

Copilot AI Nov 5, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import for ParameterOutOfRangeError which is used by the _handle_parameter_value_update method being tested. The new tests verify behavior for out-of-range parameters (lines 739-789), but the exception class is not imported. This will cause test failures when the exception is raised.

Suggested change
from ardupilot_methodic_configurator.data_model_ardupilot_parameter import ArduPilotParameter, ParameterUnchangedError
from ardupilot_methodic_configurator.data_model_ardupilot_parameter import ArduPilotParameter, ParameterUnchangedError, ParameterOutOfRangeError

Copilot uses AI. Check for mistakes.
tooltip_call_args = mock_tooltip.call_args[0]
assert "Add a parameter to the test_file.param file" in tooltip_call_args[1]

def test_create_flightcontroller_value_sets_correct_background_colors(self, parameter_editor_table) -> None: # pylint: disable=too-many-statements # noqa: PLR0915

Copilot AI Nov 5, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This test has 90+ lines and requires complexity suppression comments (too-many-statements, PLR0915). Consider breaking it into separate test methods for each background color scenario (default value, below limit, above limit, unknown bits, no FC value, normal value) to improve readability and maintainability.

Copilot uses AI. Check for mistakes.
# Assert: Correct widget was returned
assert result == mock_instance

def test_create_new_value_entry_shows_error_for_non_editable_parameters(self, parameter_editor_table) -> None:

Copilot AI Nov 5, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This test validates both forced and derived parameters in a single 95-line test method. Consider splitting into two separate test methods: test_create_new_value_entry_shows_error_for_forced_parameters and test_create_new_value_entry_shows_error_for_derived_parameters to improve clarity and make test failures easier to diagnose.

Copilot uses AI. Check for mistakes.
@amilcarlucas amilcarlucas merged commit 0384823 into master Nov 5, 2025
30 checks passed
@amilcarlucas amilcarlucas deleted the param_edit_table_tests branch November 8, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants